package com.java.escape.springproblem.applicationcontext;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;

/**
 * @ClassName UseInitializer
 * @Description 第一种方式获取应用上下文
 * @Author wyp
 * @Date 2023/9/12 9:33
 * @Version 1.0
 */
@Slf4j
public class UseInitializer implements ApplicationContextInitializer<ConfigurableApplicationContext> {
    @Override
    public void initialize(ConfigurableApplicationContext applicationContext) {
        assert ApplicationContextStore.getApplicationContext() == null;
        ApplicationContextStore.setApplicationContext(applicationContext);
        assert ApplicationContextStore.getApplicationContext() != null;
        log.info("UseInitializer Done");
    }
}
